package com.youdianda.service.impl;

import com.youdianda.dto.SysMenuUpdateDTO;
import com.youdianda.entity.SysMenu;
import com.youdianda.mapper.SysMenuMapper;
import com.youdianda.service.SysMenuService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class SysMenuServiceImpl implements SysMenuService {
    @Autowired
    private SysMenuMapper sysMenuMapper;
    /**
     * 菜单修改
     *
     * @param sysMenuUpdateDTO
     */
    @Override
    public void update(SysMenuUpdateDTO sysMenuUpdateDTO) {
        //补全数据
        SysMenu sysMenu=new SysMenu();
        sysMenu.setCreateDate(LocalDateTime.now());
        BeanUtils.copyProperties(sysMenuUpdateDTO,sysMenu);
        sysMenuMapper.updateById(sysMenu);
    }

    /**
     * 菜单删除
     *
     * @param id
     */
    @Override
    public void del(String id) {
        sysMenuMapper.deleteById(id);
    }
}
